package com.buss.admin.controller;

import com.buss.admin.entity.AuthFunctionEntity;
import com.buss.admin.entity.AuthRoleEntity;
import com.buss.admin.entity.RoleFunctionEntity;
import com.buss.admin.entity.UserRoleEntity;
import com.buss.admin.service.IAuthFunctionService;
import com.buss.admin.service.IRoleFunctionService;
import com.buss.admin.service.IRoleService;
import com.buss.admin.trans.form.RoleForm;
import com.buss.common.model.json.EasyUIDataGridResult;
import com.buss.common.model.json.HXResult;
import com.buss.common.service.SysServiceI;
import com.buss.common.util.IDUtils;
import com.buss.member.entity.RoleEntity;
import org.jweb.core.bean.PageMode;
import org.jweb.core.query.hibernate.qbc.CriteriaQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/admin/userrole")
@Controller
public class UserRoleController {
	@Autowired
	private SysServiceI sysService;
	/*
	 * 查找后台用户的角色信息
	 */
	@RequestMapping("/getrole")
	@ResponseBody
	public List geetRole(String adminid) {
		List<UserRoleEntity> userRoleEntity = this.sysService.findByProperty(UserRoleEntity.class,"user.id",adminid);
		List roles = new ArrayList<>();
		for (UserRoleEntity userE: userRoleEntity) {

			roles.add(userE.getRole().getId());
		}
		return roles;
	}


	/*
	 * 角色相关页面跳转
	 */
	@RequestMapping("/{path}")
	public String goPath(@PathVariable String path) {
		System.out.println("path:" + path);
		return "admin/role/" + path;
	}

}
